#include "EmotionLabelItem.h"

EmotionLabelItem::EmotionLabelItem(QWidget *parent)
	: QClickLabel(parent)
{
	initControl();

	connect(this, &QClickLabel::clicked, [this] {
		emit emotionClicked(emotionName);
	});
}

EmotionLabelItem::~EmotionLabelItem()
{}

void EmotionLabelItem::setEmotionName(int emotionName)
{
	this->emotionName = emotionName;
	QString emotionPath = QString(":/resource/img/emojiqq/%1.gif").arg(emotionName);
	/*apngMovie = new QMovie(emotionPath, "apng", this);
	apngMovie->start();
	apngMovie->stop();
	apngMovie->scaledSize();
	setMovie(apngMovie);*/
	QPixmap pixmap(emotionPath);
	pixmap.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
	setPixmap(pixmap);

}

void EmotionLabelItem::initControl()
{
	setObjectName("emotionLabelItem");
	setAlignment(Qt::AlignCenter);
	setFixedSize(QSize(32, 32));
	setScaledContents(true);

}
